home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / netBoot / sun3.md / cpu.map.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-14  |  9.0 KB  |  233 lines

  1. /*
  2.  * @(#)cpu.map.h 1.1 86/09/27 SMI      
  3.  * Copyright (c) 1986 by Sun Microsystems, Inc.
  4.  */
  5.  
  6. /*
  7.  * Memory Mapping and Paging on the Sun-3
  8.  *
  9.  * This file is used for both standalone code (ROM Monitor, 
  10.  * Diagnostics, boot programs, etc) and for the Unix kernel.  IF YOU HAVE
  11.  * TO CHANGE IT to fit your application, MOVE THE CHANGE BACK TO THE PUBLIC
  12.  * COPY, and make sure the change is upward-compatible.  The last thing we 
  13.  * need is seventeen different copies of this file, like we have with the
  14.  * Sun-1 header files.
  15.  */
  16.  
  17. #ifndef ADRSPC_SIZE
  18.  
  19. /*
  20.  * The address space available to a single process is 256 Megabytes.
  21.  */
  22. #define    ADRSPC_SIZE    0x10000000
  23.  
  24. /*
  25.  * The context register selects among 8 different address spaces.  Each
  26.  * address space typically corresponds to a process and is 256 megabytes.
  27.  * Each memory access is translated thru the address space indicated by
  28.  * the context register.
  29.  *
  30.  * The context register occupies a byte in control space, although only
  31.  * the low 3 bits are relevant.  The high-order bits are ignored on writes,
  32.  * and return garbage on reads.  You can mask with CONTEXTMASK.
  33.  */
  34. typedef unsigned char context_t;
  35.  
  36. #define    NUMCONTEXTS    8
  37. #define    CONTEXTMASK    (NUMCONTEXTS-1)    /* Relevant bits on read of cx reg */
  38.  
  39. /*
  40.  * The segment map determines which large pieces of the 256MB address space
  41.  * are actually in use.  Each chunk of address space is mapped to a set of
  42.  * PGSPERSEG page map entries.  Chunks which are not in use should all be
  43.  * mapped to a single set of page map entries, which should prohibit
  44.  * all accesses.
  45.  *
  46.  * There are SEGSPERCONTEXT segment map entries in each logical context.
  47.  * There are NUMPMEGS total page map entry groups (pmegs) in the physical
  48.  * page map.  Each segment map entry references a pmeg which contains
  49.  * the PGSPERSEG pages defining that segment.
  50.  *
  51.  * Note that there is much more virtual address space (256M) as there
  52.  * is physical space mappable at one time (8M).  You can't map in 256 megs
  53.  * at once even if you have that much physical memory, since the page map
  54.  * is the bottleneck here.  The solution is to "page" the page map entries
  55.  * in and out of the physical pmegs on demand.
  56.  */
  57. typedef unsigned char segnum_t; /* Segment number */
  58.  
  59. #define    SEGSPERCONTEXT    2048
  60. #define    NUMPMEGS    256
  61. #define    PGSPERSEG    16
  62.  
  63. /*
  64.  * The following are valid in the pm_type field of the page map.
  65.  */
  66. enum pm_types {
  67.     VPM_MEMORY    = 0,    /* Page is in main memory */
  68.     VPM_IO        = 1,    /* Page is onboard I/O */
  69.     VPM_VME16    = 2,    /* Page is on VMEbus, accessing 16-bit dev */
  70.     VPM_VME32    = 3,    /* Page is on VMEbus, accessing 32-bit dev */
  71.     VPM_MEMORY_NOCACHE = 4,    /* Page is in main memory, but not cacheable */
  72. };
  73.  
  74.  
  75. /*
  76.  * The following are valid in the pm_permissions field.
  77.  */
  78. enum pm_perm {
  79.     PMP_RO        = 0,    /* Page is read-only by all */
  80.     PMP_RO_SUP    = 1,    /* Page is read-only by supervisor */
  81.     PMP_ALL        = 2,    /* Page is read-write by all */
  82.     PMP_SUP        = 3,    /* Page is read-write by supervisor */
  83. };
  84.  
  85.  
  86. /*
  87.  * The page map gives fine-grain control over memory allocation.  Each page
  88.  * map entry controls BYTESPERPG (a page) of memory.  Each page can be mapped
  89.  * to memory, I/O, or a global bus (eg, VMEbus), or can be inaccessible.
  90.  * Each page can be protected against user access and can be made readable
  91.  * or read/write.  If access is denied, the
  92.  * page referenced and modified bits will not be changed, nor will the page
  93.  * number or type fields be used; so they can be used by software.
  94.  */
  95. #define    BYTESPERPG    8192
  96. #define    BYTES_PG_SHIFT    13
  97.  
  98. struct pgmapent {
  99.     unsigned    pm_valid    :1;    /* This entry is valid */
  100.     enum pm_perm    pm_permissions    :2;    /* Access privileges */
  101.     enum pm_types    pm_type        :3;    /* Type of page+don't cache */
  102.     unsigned     pm_accessed    :1;    /* Page has been read */
  103.     unsigned    pm_modified    :1;    /* Page has been written */
  104.     unsigned            :5;    /* Reserved */
  105.     unsigned    pm_page        :19;    /* Page # in physical memory */
  106. };
  107.  
  108. #define    PMREALBITS    0xFF07FFFF    /* Which are actually implemented */
  109. #define PMREALBITS_M25  0xFF0007FF      /* Which for M25 */
  110.  
  111. /*
  112.  * When the page type is PM_IO, the page number field selects
  113.  * which of the main I/O device chips is being selected.  Low-order (non-
  114.  * mapped) address bits connect to the address lines of the device and
  115.  * determine which facility of the device is being accessed.
  116.  */
  117. #define    VIOPG_KBM    0x00    /* Dual serial Z8530 SCC for keyboard&mouse */
  118. #define    VIOPG_SERIAL0    0x10    /* Dual serial Z8530 SCC */
  119. #define    VIOPG_EEPROM    0x20    /* Non-volatile memory */
  120. #define    VIOPG_CLOCK    0x30    /* Intersil 7170 time-of-day clock */
  121. #define    VIOPG_MEMORY_ERR 0x40    /* Uncorrectable Memory Error registers */
  122. #define    VIOPG_INTERRUPT    0x50    /* Interrupt control register */
  123. #define    VIOPG_ETHER    0x60    /* Intel 82586 Ethernet interface */
  124. #define    VIOPG_COLORMAP    0x70    /* Color Map for onboard video someday */
  125. #define    VIOPG_PROM    0x80    /* Bootstrap proms */
  126. #define    VIOPG_AMD_ETHER    0x90    /* AMD Ethernet interface */
  127. #define    VIOPG_SCSI    0xA0    /* Onboard SCSI interface */
  128. /*            0xB0    /* Reserved */
  129. /*            0xC0    /* Reserved */
  130. /*            0xD0    /* Reserved */
  131. #define    VIOPG_DES    0xE0    /* AMD 8068 data ciphering processor */
  132. #define    VIOPG_ECC_CTRL    0xF0    /* ECC Control Register access */
  133.  
  134.  
  135. /*
  136.  * Other special page numbers.
  137.  */
  138.  
  139. /*****************************************************************************/
  140. #ifdef PRISM
  141.             /* these are the physical page numbers */
  142. #define MEMPG_VIDEO    (0xFF000000 >> BYTES_PG_SHIFT)  /* prism bw frame buf */
  143. #define MEMPG_BW_ENABLE (0xFE400000 >> BYTES_PG_SHIFT)  /* enable plane */
  144. #define MEMPG_PRISM_CFB (0xFE800000 >> BYTES_PG_SHIFT)  /* prism color fb */
  145. #endif PRISM
  146. /*****************************************************************************/
  147.  
  148. #ifdef CARRERA
  149. #define MEMPG_VIDEO     (0xFF000000 >> BYTES_PG_SHIFT)  /* carrera frame buf */
  150. #endif CARRERA
  151.  
  152. #ifdef SIRIUS
  153. #define MEMPG_VIDEO     (0xFF000000 >> BYTES_PG_SHIFT)  /* carrera frame buf */
  154. #endif SIRIUS
  155.  
  156. #ifdef M25
  157. #define MEMPG_VIDEO      (0x00100000 >> BYTES_PG_SHIFT)  /* FB in main mem */
  158. #endif M25
  159.  
  160. #define    VMEPG_24ADDR    (0xFF000000 >> BYTES_PG_SHIFT)    /* 24-bit addr VME */
  161. #define    VMEPG_16ADDR    (0xFFFF0000 >> BYTES_PG_SHIFT)    /* 16-bit addr VME */
  162. #define    VME_COLOR_PHYS    0xFF400000    /* Base addr (not pg#) of VME color */
  163. #define    VPM_VME_COLOR    VPM_VME16    /* Page type for VME color */
  164. #define    VMEPG_COLOR    (VME_COLOR_PHYS >> BYTES_PG_SHIFT)
  165. #ifdef PRISM
  166. #define    MONBEG    MONSTART-PRISM_CFB_SIZE
  167. #else
  168. #define MONBEG  MONSTART
  169. #endif PRISM
  170.  
  171.  
  172. /*
  173.  * The maps are accessed from supervisor state by using the "movs" (Move
  174.  * Spacey) instruction.  This moves a byte, word, or longword to/from a
  175.  * register and a location in another address space.  The Sun-3 hardware
  176.  * defines one of these address spaces (defined by function code values)
  177.  * as the "control address space", including various control registers
  178.  * as well as the maps.  The particular map accessed is determined
  179.  * by the high-order 4 bits of the address used.  The particular entry accessed
  180.  * is determined by the middle-order bits of the address used --
  181.  * we access the entry that controls that page.  Which particular byte(s) of
  182.  * the map entry are accessed is controlled by the low-order bits of the
  183.  * address used, as usual.
  184.  *
  185.  * The following defines the encodings for the various address spaces used
  186.  * by "movs".
  187.  */
  188. #define    FC_UD    1    /* User Data */
  189. #define    FC_UP    2    /* User Program */
  190. #define    FC_MAP    3    /* Sun-3 Memory Maps */
  191. #define    FC_SD    5    /* Supervisor Data */
  192. #define    FC_SP    6    /* Supervisor Program */
  193. #define    FC_CPU    7    /* CPU Space (Int Ack, Co-processors, ...) */
  194.  
  195. #define    SEGMAPADR(addr)    (char *)(((int)addr&MAPADDRMASK)+SMAPOFF)
  196. #define    PAGEMAPADR(addr)(long *)(((int)addr&MAPADDRMASK)+PMAPOFF)
  197.  
  198. #define    IDPROMOFF    0x00000000    /* ID Prom */
  199. #define    PMAPOFF        0x10000000    /* Page map offset within maps */
  200. #define    SMAPOFF        0x20000000    /* Segment map offset within maps */
  201. #define    CONTEXTOFF    0x30000000    /* Context registers */
  202. #define    ENABLEOFF    0x40000000    /* System Enable Reg -- turns me on */
  203. #define    UDMAENABLEOFF    0x50000000    /* User DVMA Enable Reg */
  204. #define    BUSERROFF    0x60000000    /* Bus Error Register - tells why */
  205. #define    LEDOFF        0x70000000    /* LED's for diagnostics -- 0=lit */
  206. #define    SERIALOFF    0xF0000000    /* Serial port bypass for diagnostics */
  207.  
  208. #define    MAPADDRMASK    0x0FFFE000    /* Keeps bits relevant to map entry */
  209.  
  210.  
  211. /*
  212.  * The following subroutines accept any address in the mappable range
  213.  * (256 megs).  They access the map for the current context.  They
  214.  * assume that we are currently running in supervisor state.
  215.  *
  216.  * We can't declare getpgmap() as returning a struct, because our C compiler
  217.  * is brain damaged and returns a pointer to a static area if you return a
  218.  * struct.  We therefore return an int and require the caller to set up
  219.  * unions and other assorted random hacks because the language
  220.  * implementation doesn't support structures returned from reentrant routines.
  221.  */ 
  222.  
  223. extern /*struct pgmapent*/ getpgmap();    /* (addr) */
  224. extern                     setpgmap();    /* (addr, entry) */
  225. extern segnum_t getsegmap();        /* (addr) */
  226. extern          setsegmap();        /* (addr, entry) */
  227. extern context_t getsupcontext();    /* () */
  228. extern           setsupcontext();    /* (entry) */
  229. extern context_t getusercontext();    /* () */
  230. extern           setusercontext();    /* (entry) */
  231.  
  232. #endif ADRSPC_SIZE
  233.